/*
*
* 版权所有 Copyleft(c) 2005
* 刘炯个人工作室 Sharp-Mark Personal Studio
*
* 允许自由使用，复制，修改，传播和贩卖此源程序及其文档，而不必支付任何费用。
* 以上的版权信息必须出现在每一份复制品中。同时这份版权信息和许可声明
* 也必须出现在支持文档中。刘炯个人工作室不对此软件适于那种具体
* 用途做出任何阐述。此代码只作为代码本身提供对其品质不做任何保证。
*
*/

// ChildView.cpp : CChildView 类的实现

#include "stdafx.h"
#include "DDALine.h"
#include "ChildView.h"
#include ".\childview.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#include "../SharpmarkGraphicsLib/Line/Line.h"
// CChildView

CChildView::CChildView()
{
	_isClick = false;
	_pointText = "(  0,   0)";
}

CChildView::~CChildView()
{
}


BEGIN_MESSAGE_MAP(CChildView, CWnd)
	ON_WM_PAINT()
	ON_WM_LBUTTONDOWN()
	ON_WM_MOUSEMOVE()
//	ON_WM_CREATE()
END_MESSAGE_MAP()



// CChildView 消息处理程序

BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs) 
{
	if (!CWnd::PreCreateWindow(cs))
		return FALSE;

	cs.dwExStyle |= WS_EX_CLIENTEDGE;
	cs.style &= ~WS_BORDER;
	cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, 
		::LoadCursor(NULL, IDC_ARROW), reinterpret_cast<HBRUSH>(COLOR_WINDOW+1), NULL);

	return TRUE;
}

void CChildView::OnPaint() 
{
	CPaintDC dc(this); // 用于绘制的设备上下文

	//srand( ( unsigned ) time( 0 ) );

	//CRect rect;
	//GetClientRect( &rect );

	//for ( int i = 0; i < 10; i++ )
	//{
	//	if( _isClick )
	//	{
	//		_x0[i] = rand() % rect.Width();
	//		_y0[i] = rand() % rect.Height();
	//		_x1[i] = rand() % rect.Width();
	//		_y1[i] = rand() % rect.Height();
	//	}
	//	//x0 = 653;
	//	//y0 = 116;

	//	//x1 = 678;
	//	//y1 = 167;
	//	ZergLine( _x0[i], _y0[i], _x1[i], _y1[i], RGB(0, 0, 255), dc);
	//	Draw_Line( _x0[i], _y0[i], _x1[i], _y1[i], RGB(255, 0, 0), dc);

	//	//dc.SetDCPenColor( RGB( 255, 0 ,0 ) );
	//	dc.MoveTo( _x0[i], _y0[i] );
	//	dc.LineTo( _x1[i], _y1[i] );

	//	dc.TextOut(0, 0, _pointText);
	//	//BresenhamLine_Zeng( x0, y0, x1, y1, RGB(0, 0, 255), dc);
	//	//BresenhamLine_Tsinghua( x0, y0, x1, y1, RGB( 0, 255, 0 ), dc );
	//	//DDALine( x0, y0, x1, y1 , RGB( 255, 0, 0 ), dc );

	//}


	//
	//int x0, x1, y0 ,y1;

	//x0 = 653;
	//y0 = 116;

	//x1 = 678;
	//y1 = 167;

	//clock_t start, end;

	//COLORREF color = RGB(0, 0, 255);

	//CString text;

	//start = clock();
	//for (int i = 0; i < 100000; i++)
	//{
	//	//x0 = rand() % rect.Width();
	//	//y0 = rand() % (rect.Height() -48) + 48;
	//	//x1 = rand() % rect.Width();
	//	//y1 = rand() % (rect.Height() - 48) + 48;

	//	//DDALine(x0, y0, x1, y1, RGB(rand() % 256, rand() % 256, rand() % 256), dc);
	//	DDALine(x0, y0, x1, y1, RGB(0, 0, 255), dc);
	//}
	//end = clock();
	//text.Format("the time DDALine spent was : %.5f", (float(end - start) / CLK_TCK));
	//dc.TextOut(0, 0, text);

	//color = RGB(0, 255, 0);
	//start = clock();
	//for (int i = 0; i < 100000; i++)
	//{
	//	//x0 = rand() % rect.Width();
	//	//y0 = rand() % (rect.Height() -48) + 48;
	//	//x1 = rand() % rect.Width();
	//	//y1 = rand() % (rect.Height() - 48) + 48;

	//	//ZergLine(x0, y0, x1, y1, RGB(rand() % 256, rand() % 256, rand() % 256), dc);
	//	ZergLine(x0, y0, x1, y1, color, dc);
	//}
	//end = clock();
	//text.Format("the time Bresenham spent was : %.5f", (float(end - start) / CLK_TCK));
	//dc.TextOut(0, 16, text);

	//start = clock();
	//for (int i = 0; i < 100000; i++)
	//{
	//	//x0 = rand() % rect.Width();
	//	//y0 = rand() % (rect.Height() -48) + 48;
	//	//x1 = rand() % rect.Width();
	//	//y1 = rand() % (rect.Height() - 48) + 48;
	//	
	//	dc.MoveTo(x0, y0);
	//	dc.LineTo(x1, y1);
	//}
	//end = clock();
	//text.Format("the time Microsoft spent was : %.5f", (float(end - start) / CLK_TCK));
	//dc.TextOut(0, 32, text);

	//color = RGB(255, 0, 0);
	//start = clock();
	//for (int i = 0; i < 100000; i++)
	//{
	//	//x0 = rand() % rect.Width();
	//	//y0 = rand() % (rect.Height() -48) + 48;
	//	//x1 = rand() % rect.Width();
	//	//y1 = rand() % (rect.Height() - 48) + 48;

	//	Draw_Line(x0, y0, x1, y1, color, dc);
	//}
	//end = clock();
	//text.Format("the time Bresenham spent was : %.5f", (float(end - start) / CLK_TCK));
	//dc.TextOut(0, 48, text);

	BresenhamLine_Sharpmark(0, 0, 500, 340, RGB(0, 255, 0), dc);
}


void CChildView::OnLButtonDown(UINT nFlags, CPoint point)
{
	//_isClick = true;
	Invalidate();
	UpdateWindow();
	//_isClick = false;
}


void CChildView::OnMouseMove(UINT nFlags, CPoint point)
{
	//_pointText.Format("(%4d, %4d)", point.x, point.y);

	//Invalidate();
	//UpdateWindow();
}
